package com.aliothservice.catfish.order.data;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.Map;

import org.springframework.data.annotation.Id;

public class Transaction {
	
	public static final String STATUS_COMPLETED_ORDER = "completed_order";
	public static final String STATUS_WITHDRAW = "withdraw";
	
	public Map<String, Object> toMap() {
		Map<String, Object> map = new HashMap<String, Object>();
		
		map.put("title", this.getTitle());
		map.put("priceTotal", this.getPriceTotal());
		map.put("unitPrice", this.getUnitPrice());
		map.put("volume", this.getVolume());
		map.put("orderNumber", this.getOrderNumber());
		if (null != this.getAlipayOrderNumber()) {
			map.put("alipayOrderNumber", this.getAlipayOrderNumber());
		}
		map.put("status", this.getStatus());
		DateTimeFormatter fullFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss:SSS");
		map.put("creationDate", fullFormatter.format(this.getCreationDate()));
		map.put("orderCreationDate", fullFormatter.format(this.getOrderCreationDate()));
		map.put("orderPaidDate", fullFormatter.format(this.getOrderPaidDate()));
		if (null != this.getPhotoId()) {
			map.put("photoId", this.getPhotoId());
		}
		
		return map;
	}
	
	@Id
	private String id;
	
	private String userId;
	
	private String title;
	private LocalDateTime creationDate;
	private Float priceTotal;
	private Float unitPrice;
	private Integer volume;
	private String orderNumber;
	private String alipayOrderNumber;
	
	private LocalDateTime orderCreationDate;
	private LocalDateTime orderPaidDate;
	private String photoId;
	private String status;

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public LocalDateTime getCreationDate() {
		return creationDate;
	}

	public void setCreationDate(LocalDateTime creationDate) {
		this.creationDate = creationDate;
	}

	public Float getPriceTotal() {
		return priceTotal;
	}

	public void setPriceTotal(Float priceTotal) {
		this.priceTotal = priceTotal;
	}

	public String getOrderNumber() {
		return orderNumber;
	}

	public void setOrderNumber(String orderNumber) {
		this.orderNumber = orderNumber;
	}

	public String getAlipayOrderNumber() {
		return alipayOrderNumber;
	}

	public void setAlipayOrderNumber(String alipayOrderNumber) {
		this.alipayOrderNumber = alipayOrderNumber;
	}

	public LocalDateTime getOrderCreationDate() {
		return orderCreationDate;
	}

	public void setOrderCreationDate(LocalDateTime orderCreationDate) {
		this.orderCreationDate = orderCreationDate;
	}

	public LocalDateTime getOrderPaidDate() {
		return orderPaidDate;
	}

	public void setOrderPaidDate(LocalDateTime orderPaidDate) {
		this.orderPaidDate = orderPaidDate;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public Float getUnitPrice() {
		return unitPrice;
	}

	public void setUnitPrice(Float unitPrice) {
		this.unitPrice = unitPrice;
	}

	public Integer getVolume() {
		return volume;
	}

	public void setVolume(Integer volume) {
		this.volume = volume;
	}

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public String getPhotoId() {
		return photoId;
	}

	public void setPhotoId(String photoId) {
		this.photoId = photoId;
	}

}
